from machine import Pin
from machine import Timer
import bluetooth
from car import CAR

def ble1()
    if BLE_MSG == 'read_LED':
        print(BLE_MSG)
        BLE_MSG = ""
        print('LED is ON.' if led.value() else 'LED is OFF')
        ble.send('LED is ON.' if led.value() else 'LED is OFF')
    elif BLE_MSG:
        print("接收到的信息：>>%s<<" % BLE_MSG)
        if BLE_MSG == ("!B11:" or "!B10;") :  # 按下app上数字1
            Car.up_left()
        elif BLE_MSG == ("!B219" or "!B20:") :  # 按下app上数字2
            Car.up_right()
        elif BLE_MSG == ("!B309" or "!B318") :  # 按下app上数字3
            Car.Counterclockwise()
            speed = speed + 10
            Car.setspeed(speed)
            ble.send('占空比为：'+ str(Car.duty       )+'(最大为1023)')
        elif BLE_MSG == ("!B417" or "!B408") :  # 按下app上数字4
            Car.clockwise()
            speed = speed - 10
            Car.setspeed(speed)
            ble.send('占空比为：'+ str(Car.duty       )+'(最大为1023)')
        elif BLE_MSG == ("!B516" or "!B507") :  # 按下app上up键
            Car.up()
        elif BLE_MSG == ("!B705" or "!B714") :  # 按下app上left键
            Car.left()
        elif BLE_MSG == ("!B813" or "!B804") :  # 按下app上right键
            Car.right()
        elif BLE_MSG == ("!B615" or "!B606") :  # 按下app上down键
            Car.down()
        BLE_MSG = ""
